/** 查询用户列表 */
export function listUserApi(query: UserRecord): Promise<ApiRowsRecord<UserRecord[]>> {
  return request({
    url: `system/user/list`,
    method: 'get',
    params: query
  })
}

/** 查询用户详细 */
export function getUserApi(id: number): Promise<ApiDataRecord<UserRecord>> {
  return request({
    url: `system/user/${id}`,
    method: 'get'
  })
}

/** 新增用户 */
export function addUserApi(data: UserRecord): Promise<ApiRecord> {
  return request({
    url: "system/user",
    method: 'post',
    data: data
  })
}

/** 修改用户 */
export function updateUserApi(data: UserRecord): Promise<ApiRecord> {
  return request({
    url: "system/user",
    method: 'put',
    data: data
  })
}

/** 删除用户 */
export function delUserApi(id: number[]): Promise<ApiRecord> {
  return request({
    url: `system/user/${id}`,
    method: 'delete',
  })
}

/** 用户密码重置 */
export function resetUserPwdApi(data: UserRecord): Promise<ApiRecord> {
  return request({
    url: '/system/user/resetPwd',
    method: 'put',
    data: data
  })
}

/** 查询授权角色 */
export function getAuthRoleApi(userId: number): Promise<ApiRecord> {
  return request({
    url: '/system/user/authRole/' + userId,
    method: 'get'
  })
}

/** 保存授权角色 */
export function updateAuthRoleApi(data: RoleAuthRecord): Promise<ApiRecord> {
  return request({
    url: '/system/user/authRole',
    method: 'put',
    params: data
  })
}
